package com.orientsec.autotest.project.system.targetstrucdetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.targetstrucdetail.domain.Targetstrucdetail;
import com.orientsec.autotest.project.system.targetstrucdetail.service.ITargetstrucdetailService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 目标文件结构配置详情信息操作处理
 * 
 * @author autotest
 * @date 2019-12-27
 */
@Controller
@RequestMapping("/system/targetstrucdetail")
public class TargetstrucdetailController extends BaseController
{
    private String prefix = "system/targetstrucdetail";
	
	@Autowired
	private ITargetstrucdetailService targetstrucdetailService;
	
	@RequiresPermissions("system:targetstrucdetail:view")
	@GetMapping()
	public String targetstrucdetail()
	{
	    return prefix + "/targetstrucdetail";
	}
	
	/**
	 * 查询目标文件结构配置详情列表
	 */
	@RequiresPermissions("system:targetstrucdetail:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Targetstrucdetail targetstrucdetail)
	{
		startPage();
        List<Targetstrucdetail> list = targetstrucdetailService.selectTargetstrucdetailList(targetstrucdetail);
		return getDataTable(list);
	}


	/**
	 * 查询目标文件结构配置详情列表
	 */
	@RequiresPermissions("system:targetstrucdetail:list")
	@RequestMapping("/list/{id}")
	public String list(@PathVariable("id") Integer id,ModelMap mmap)
	{
        mmap.put("ssid",id);
		return prefix + "/targetstrucdetail";
	}




	/**
	 * 导出目标文件结构配置详情列表
	 */
	@RequiresPermissions("system:targetstrucdetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Targetstrucdetail targetstrucdetail)
    {
    	List<Targetstrucdetail> list = targetstrucdetailService.selectTargetstrucdetailList(targetstrucdetail);
        ExcelUtil<Targetstrucdetail> util = new ExcelUtil<Targetstrucdetail>(Targetstrucdetail.class);
        return util.exportExcel(list, "targetstrucdetail");
    }
	
	/**
	 * 新增目标文件结构配置详情
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存目标文件结构配置详情
	 */
	@RequiresPermissions("system:targetstrucdetail:add")
	@Log(title = "目标文件结构配置详情", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Targetstrucdetail targetstrucdetail)
	{		
		return toAjax(targetstrucdetailService.insertTargetstrucdetail(targetstrucdetail));
	}

	/**
	 * 修改目标文件结构配置详情
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Targetstrucdetail targetstrucdetail = targetstrucdetailService.selectTargetstrucdetailById(id);
		mmap.put("targetstrucdetail", targetstrucdetail);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存目标文件结构配置详情
	 */
	@RequiresPermissions("system:targetstrucdetail:edit")
	@Log(title = "目标文件结构配置详情", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Targetstrucdetail targetstrucdetail)
	{		
		return toAjax(targetstrucdetailService.updateTargetstrucdetail(targetstrucdetail));
	}
	
	/**
	 * 删除目标文件结构配置详情
	 */
	@RequiresPermissions("system:targetstrucdetail:remove")
	@Log(title = "目标文件结构配置详情", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(targetstrucdetailService.deleteTargetstrucdetailByIds(ids));
	}
	
}
